# 统一错误处理
from flask import Blueprint, jsonify
from marshmallow.exceptions import ValidationError

error = Blueprint('error', __name__)

# app_errorhandler调用该方法做错误处理
# 捕获ValidationError异常并返回异常信息
@error.app_errorhandler(ValidationError)
def handle_valid_error(e):

    result_dict = jsonify({'status_code': 400, 'status_message': e.messages})

    return result_dict
